#import "InsetsLabel.h"

@implementation InsetsLabel
@synthesize insets=_insets;
-(id) initWithFrame:(CGRect)frame andInsets:(UIEdgeInsets)insets {
    self = [super initWithFrame:frame];
    if(self){
        self.insets = insets;
    }
    return self;
}

-(id) initWithInsets:(UIEdgeInsets)insets {
    self = [super init];
    if(self){
        self.insets = insets;
    }
    return self;
}

-(void) drawTextInRect:(CGRect)rect {
    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.insets)];
}

- (void)setBackgroundColor:(UIColor *)color {
    // do nothing - background color never changes
    if(CGColorEqualToColor([UIColor clearColor].CGColor, color.CGColor)){
        return;
    }
    [super setBackgroundColor:color];
}

@end
